package com.feature.shop.auth.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.feature.shop.auth.api.constant.AuthMqConstatns;

@Configuration
public class RabbitMqConfig {
	/**
	 * 登录成功交换机
	 *
	 * @return
	 */
	@Bean
	DirectExchange shopLoginSuccessExchange() {
		return new DirectExchange(AuthMqConstatns.SHOP_LOGIN_SUCCESS_EXCHANGE);
	}

	/**
	 * 登录成功队列
	 *
	 * @return
	 */
	@Bean
	Queue shopLoginSuccessQueue() {
		return new Queue(AuthMqConstatns.SHOP_LOGIN_SUCCESS_QUEUE);
	}

	/**
	 * 绑定登录成功队列
	 *
	 * @param queue
	 * @param exchange
	 * @return
	 */
	@Bean
	Binding uploadCheckUserSummaryExchangeQueueBinding(@Qualifier("shopLoginSuccessQueue") Queue queue, @Qualifier("shopLoginSuccessExchange") DirectExchange exchange) {
		return BindingBuilder.bind(queue).to(exchange).with(AuthMqConstatns.SHOP_LOGIN_SUCCESS_ROUTING_KEY);
	}

}
